﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iit.ITBI.MDSManager;

namespace Iit.ITBI.MDSManagerPOC
{
    class Program
    {    

        delegate void OnErrorEventHandler(object sender, EventArgs e);

        static void Main(string[] args)
        {

            
            
            
            //MasterEntityReplicator masterEntityReplicator = new MasterEntityReplicator(new Uri(@"http://saxodkdev7018:82/service/service.svc"), @"Server=SAXODKDEV7018\RAFADEV;Database=MDS_2012_2012;Trusted_Connection=True;");

            MasterEntityReplicator masterEntityReplicator = new MasterEntityReplicator();

            masterEntityReplicator.OnInfo += masterEntityReplicator_OnInfo;
            masterEntityReplicator.OnWarning += masterEntityReplicator_OnWarning;
            masterEntityReplicator.OnError += masterEntityReplicator_OnError;


            masterEntityReplicator.InstallMasterToEntityMappingEntity();

            Console.WriteLine("Press any key to exit");
            //Console.ReadLine();
            //return;

            Console.WriteLine("Start to replicate");

            masterEntityReplicator.Replicate();

            Console.WriteLine("Replication ended");
            Console.WriteLine();

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }

        static public void masterEntityReplicator_OnInfo(object sender, MessageEventArgs e)        
        {
            Console.WriteLine(e.Message);
        }

        static public void masterEntityReplicator_OnError(object sender, MessageEventArgs e)
        {
            Console.WriteLine(e.Message);
        }

        static public void masterEntityReplicator_OnWarning(object sender, MessageEventArgs e)
        {
            Console.WriteLine(e.Message);
        }
        



    }
}
